﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using KVB.Common;
using Customer_Profile.CRM.DBDao;
using Customer_Profile.Admin;


namespace Customer_Profile.CRM
{
    public partial class SMSList : System.Web.UI.Page
    {
        string strUserName = "";
        string strUserID = "";
        string strEntity = "";
        protected void Page_Load(object sender, EventArgs e)
        {
            Comm.CheckSession(this.Page, "/login.aspx", "usermodel");
            if (Session["usermodel"] != null)
            {
                strUserID = ((UserInfoEntity)Session["usermodel"]).UserLoginId;
                strUserName = ((UserInfoEntity)Session["usermodel"]).UserName;
                strEntity = ((UserInfoEntity)Session["usermodel"]).UserOffice;
            }
            else
            {
                Log.WriteDefaultLog("main_01 Page_Load", "Session is null");
                return;
            }            
            bindGrid();
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {

        }

        private void bindGrid()
        {            
            string strStartDate = txtcreatedatebegin.Text.Trim();
            string strEndDate = txtcreatedateend.Text.Trim();

            string strWhere = "";
            if (!strStartDate.Equals("") && !strEndDate.Equals(""))
            {
                strWhere += " AND input_datetime between '" + strStartDate + "' and '" + strEndDate + "'";
            }

            if (txtTitle.Text.Trim() != "")
            {
                strWhere += " AND sms_title like '%" + txtTitle.Text.Trim() + "%'";
            }

            DataSet ds = SmsDao.getSMSList(strWhere);
            gridReward.DataSource = ds;
            gridReward.DataBind();
        }
    }
}